package net.dgg.dggcloud.service.jrcrm.entity.customer;

import net.dgg.dggcloud.core.util.DateUtil;
import net.dgg.dggcloud.core.util.StringUtils;
import net.dgg.dggcloud.service.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * @ClassName: AttrBuilding-客户房产信息
 * @Description: 用于客户房产信息维护
 * @Author: 周潮
 * @Date: 2017年11月03 14:28:28
 * @Version V1.0
 */
@Entity
@Table(name = "cus_attr_building")
public class AttrBuilding extends BaseEntity {

    //数据库表名
    public static final String TABLE_NAME = "cus_attr_building";

    /**
     * 客户id 
     */
    @Column(name = "customer_id")
    private Long customerId;

    /**
     * 房产所有内容前台展示用
     */
    @Transient
    private String frontShow;

    /**
     * 支付方式 1全款，2按揭
     */
    @Column(name = "pay_type")
    private Integer payType;

    /**
     * 支付方式-前台展示用
     */
    @Transient
    private String payTypeShow;

    /**
     * 房屋类型 
     */
    @Column(name = "building_type")
    private String buildingType;

    /**
     * 房屋类型 -前台展示用
     */
    @Transient
    private String buildingTypeShow;

    /**
     * 建立时间 
     */
    @Column(name = "built_up_time")
    private String builtUpTime;

    /**
     * 建立时间 -前台展示用
     */
    @Transient
    private String builtUpTimeShow;

    /**
     * 房屋位置 
     */
    @Column(name = "building_position")
    private String buildingPosition;

    /**
     * 房屋位置 -前台展示用
     */
    @Transient
    private String buildingPositionShow;

    /**
     * 房屋面积 
     */
    @Column(name = "building_area")
    private String buildingArea;

    /**
     * 房屋面积 -前台展示用
     */
    @Transient
    private String buildingAreaShow;

    /**
     * 市场价格 
     */
    @Column(name = "market_price")
    private Double marketPrice;

    /**
     * 市场价格 -前台展示用
     */
    @Transient
    private String marketPriceShow;

    /**
     * 房产证 
     */
    @Column(name = "certificate")
    private String certificate;

    /**
     * 房产证 -前台展示用
     */
    @Transient
    private String certificateShow;

    /**
     * 拿证时间 
     */
    @Column(name = "taking_time")
    private Date takingTime;

    /**
     * 拿证时间 -前台展示用
     */
    @Transient
    private String takingTimeShow;

    /**
     * 是否可以交易 
     */
    @Column(name = "is_trade")
    private Integer isTrade;

    /**
     * 是否可以交易 -前台展示用
     */
    @Transient
    private String isTradeShow;

    /**
     * 按揭银行 
     */
    @Column(name = "mortgage_bank")
    private String mortgageBank;

    /**
     * 按揭银行 -前台展示用
     */
    @Transient
    private String mortgageBankShow;

    /**
     * 按揭金额 
     */
    @Column(name = "mortgage_amount")
    private Double mortgageAmount;

    /**
     * 按揭金额 -前台展示用
     */
    @Transient
    private String mortgageAmountShow;

    /**
     * 按揭开始时间 
     */
    @Column(name = "mortgage_time")
    private Date mortgageTime;

    /**
     * 按揭开始时间 -前台展示用
     */
    @Transient
    private String mortgageTimeShow;

    /**
     * 月供 
     */
    @Column(name = "month_pay")
    private Double monthPay;

    /**
     * 月供 -前台展示用
     */
    @Transient
    private String monthPayShow;

    /**
     * 按揭年限 
     */
    @Column(name = "mortgage_years")
    private Double mortgageYears;

    /**
     * 按揭年限 -前台展示用
     */
    @Transient
    private String mortgageYearsShow;

    /**
     * 按揭利率 
     */
    @Column(name = "mortgage_rate")
    private Float mortgageRate;

    /**
     * 按揭年限 -前台展示用
     */
    @Transient
    private String mortgageRateShow;

    /**
     * 按揭方式 
     */
    @Column(name = "mortgage_way")
    private String mortgageWay;

    /**
     * 按揭方式 -前台展示用
     */
    @Transient
    private String mortgageWayShow;

    /**
     * 还款方式
     */
    @Column(name = "repayment_way")
    private String repaymentWay;

    /**
     * 还款方式 -前台展示用
     */
    @Transient
    private String repaymentWayShow;

    /**
     * 外部系统读取标志 预留扩展字段，每外部系统占用一位，如1001
     */
    @Column(name = "read_flag")
    private String readFlag;

    /**
     * 外部系统来源标志 预留扩展字段，每外部系统占用一位，如1001
     */
    @Column(name = "source_flag")
    private String sourceFlag;

    /**
     * 扩展字段1 
     */
    @Column(name = "ext1")
    private String ext1;

    /**
     * 扩展字段2 
     */
    @Column(name = "ext2")
    private String ext2;

    /**
     * 扩展字段3 
     */
    @Column(name = "ext3")
    private String ext3;

    /**
     * 扩展字段4 
     */
    @Column(name = "ext4")
    private String ext4;

    /**
     * 扩展字段5 
     */
    @Column(name = "ext5")
    private String ext5;

    /**
     * 扩展字段6 
     */
    @Column(name = "ext6")
    private String ext6;

    /**
     * 扩展字段7 
     */
    @Column(name = "ext7")
    private String ext7;

    /**
     * 扩展字段8 
     */
    @Column(name = "ext8")
    private String ext8;

    /**
     * 扩展字段9 
     */
    @Column(name = "ext9")
    private String ext9;

    /**
     * 扩展字段10 
     */
    @Column(name = "ext10")
    private String ext10;

    /**
     * 扩展字段11 
     */
    @Column(name = "ext11")
    private String ext11;

    /**
     * 扩展字段12 
     */
    @Column(name = "ext12")
    private String ext12;

    /**
     * 扩展字段13 
     */
    @Column(name = "ext13")
    private String ext13;

    /**
     * 扩展字段14 
     */
    @Column(name = "ext14")
    private String ext14;

    /**
     * 扩展字段15 
     */
    @Column(name = "ext15")
    private String ext15;

    /**
     * 外部系统读取标志 预留扩展字段，每外部系统占用一位，如1001
     * @return read_flag 外部系统读取标志 预留扩展字段，每外部系统占用一位，如1001
     */
    public String getReadFlag() {
        return readFlag;
    }

    /**
     * 外部系统读取标志 预留扩展字段，每外部系统占用一位，如1001
     * @param readFlag 外部系统读取标志 预留扩展字段，每外部系统占用一位，如1001
     */
    public void setReadFlag(String readFlag) {
        this.readFlag = readFlag == null ? null : readFlag.trim();
    }

    /**
     * 外部系统来源标志 预留扩展字段，每外部系统占用一位，如1001
     * @return source_flag 外部系统来源标志 预留扩展字段，每外部系统占用一位，如1001
     */
    public String getSourceFlag() {
        return sourceFlag;
    }

    /**
     * 外部系统来源标志 预留扩展字段，每外部系统占用一位，如1001
     * @param sourceFlag 外部系统来源标志 预留扩展字段，每外部系统占用一位，如1001
     */
    public void setSourceFlag(String sourceFlag) {
        this.sourceFlag = sourceFlag == null ? null : sourceFlag.trim();
    }

    /**
     * 客户id 
     * @return customer_id 客户id 
     */
    public Long getCustomerId() {
        return customerId;
    }

    /**
     * 客户id 
     * @param customerId 客户id 
     */
    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    /**
     * 支付方式 1全款，2按揭
     * @return pay_type 支付方式 1全款，2按揭
     */
    public Integer getPayType() {
        return payType;
    }

    /**
     * 支付方式 1全款，2按揭
     * @param payType 支付方式 1全款，2按揭
     */
    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    /**
     * 房屋类型 
     * @return building_type 房屋类型 
     */
    public String getBuildingType() {
        return buildingType;
    }

    /**
     * 房屋类型 
     * @param buildingType 房屋类型 
     */
    public void setBuildingType(String buildingType) {
        this.buildingType = buildingType == null ? null : buildingType.trim();
    }

    /**
     * 建立时间 
     * @return built_up_time 建立时间 
     */
    public String getBuiltUpTime() {
        return builtUpTime;
    }

    /**
     * 建立时间 
     * @param builtUpTime 建立时间 
     */
    public void setBuiltUpTime(String builtUpTime) {
        this.builtUpTime = builtUpTime;
    }

    /**
     * 房屋位置 
     * @return building_position 房屋位置 
     */
    public String getBuildingPosition() {
        return buildingPosition;
    }

    /**
     * 房屋位置 
     * @param buildingPosition 房屋位置 
     */
    public void setBuildingPosition(String buildingPosition) {
        this.buildingPosition = buildingPosition == null ? null : buildingPosition.trim();
    }

    /**
     * 房屋面积 
     * @return building_area 房屋面积 
     */
    public String getBuildingArea() {
        return buildingArea;
    }

    /**
     * 房屋面积 
     * @param buildingArea 房屋面积 
     */
    public void setBuildingArea(String buildingArea) {
        this.buildingArea = buildingArea;
    }

    /**
     * 市场价格 
     * @return market_price 市场价格 
     */
    public Double getMarketPrice() {
        return (null != marketPrice ? marketPrice/1000000 : null);
    }

    /**
     * 市场价格 
     * @param marketPrice 市场价格 
     */
    public void setMarketPrice(Double marketPrice) {
        this.marketPrice = (null != marketPrice ? marketPrice*1000000 : null);
    }

    /**
     * 房产证 
     * @return certificate 房产证 
     */
    public String getCertificate() {
        return certificate;
    }

    /**
     * 房产证 
     * @param certificate 房产证 
     */
    public void setCertificate(String certificate) {
        this.certificate = certificate;
    }

    /**
     * 拿证时间 
     * @return taking_time 拿证时间 
     */
    public Date getTakingTime() {
        return takingTime;
    }

    /**
     * 拿证时间 
     * @param takingTime 拿证时间 
     */
    public void setTakingTime(Date takingTime) {
        this.takingTime = takingTime;
    }

    /**
     * 是否可以交易 
     * @return is_trade 是否可以交易 
     */
    public Integer getIsTrade() {
        return isTrade;
    }

    /**
     * 是否可以交易 
     * @param isTrade 是否可以交易 
     */
    public void setIsTrade(Integer isTrade) {
        this.isTrade = isTrade;
    }

    /**
     * 按揭银行 
     * @return mortgage_bank 按揭银行 
     */
    public String getMortgageBank() {
        return mortgageBank;
    }

    /**
     * 按揭银行 
     * @param mortgageBank 按揭银行 
     */
    public void setMortgageBank(String mortgageBank) {
        this.mortgageBank = mortgageBank == null ? null : mortgageBank.trim();
    }

    /**
     * 按揭金额 
     * @return mortgage_amount 按揭金额
     */
    public Double getMortgageAmount() {
        return (null != mortgageAmount ? mortgageAmount/100 : null);
    }

    /**
     * 按揭金额 
     * @param mortgageAmount 按揭金额
     */
    public void setMortgageAmount(Double mortgageAmount) {
        this.mortgageAmount = (null != mortgageAmount ? mortgageAmount*100 : null);
    }

    /**
     * 按揭开始时间 
     * @return mortgage_time 按揭开始时间 
     */
    public Date getMortgageTime() {
        return mortgageTime;
    }

    /**
     * 按揭开始时间 
     * @param mortgageTime 按揭开始时间 
     */
    public void setMortgageTime(Date mortgageTime) {
        this.mortgageTime = mortgageTime;
    }

    /**
     * 月供 
     * @return month_pay 月供 
     */
    public Double getMonthPay() {
        return (null != monthPay ? monthPay/100 : null);
    }

    /**
     * 月供 
     * @param monthPay 月供 
     */
    public void setMonthPay(Double monthPay) {
        this.monthPay = (null != monthPay ? monthPay*100 : null);
    }

    /**
     * 按揭年限 
     * @return mortgage_years 按揭年限 
     */
    public Double getMortgageYears() {
        return mortgageYears;
    }

    /**
     * 按揭年限 
     * @param mortgageYears 按揭年限 
     */
    public void setMortgageYears(Double mortgageYears) {
        this.mortgageYears = mortgageYears;
    }

    /**
     * 按揭利率 
     * @return mortgage_rate 按揭利率 
     */
    public Float getMortgageRate() {
        return (null != mortgageRate ? mortgageRate*100 : null);
    }

    /**
     * 按揭利率 
     * @param mortgageRate 按揭利率 
     */
    public void setMortgageRate(Float mortgageRate) {
        this.mortgageRate = (null != mortgageRate ? mortgageRate/100 : null);
    }

    /**
     * 按揭方式 
     * @return mortgage_way 按揭方式 
     */
    public String getMortgageWay() {
        return mortgageWay;
    }

    /**
     * 按揭方式 
     * @param mortgageWay 按揭方式 
     */
    public void setMortgageWay(String mortgageWay) {
        this.mortgageWay = mortgageWay == null ? null : mortgageWay.trim();
    }

    /**
     * 还款方式 
     * @return repayment_way 还款方式 
     */
    public String getRepaymentWay() {
        return repaymentWay;
    }

    /**
     * 还款方式 
     * @param repaymentWay 还款方式 
     */
    public void setRepaymentWay(String repaymentWay) {
        this.repaymentWay = repaymentWay == null ? null : repaymentWay.trim();
    }

    /**
     * 扩展字段1 
     * @return ext1 扩展字段1 
     */
    public String getExt1() {
        return ext1;
    }

    /**
     * 扩展字段1 
     * @param ext1 扩展字段1 
     */
    public void setExt1(String ext1) {
        this.ext1 = ext1 == null ? null : ext1.trim();
    }

    /**
     * 扩展字段2 
     * @return ext2 扩展字段2 
     */
    public String getExt2() {
        return ext2;
    }

    /**
     * 扩展字段2 
     * @param ext2 扩展字段2 
     */
    public void setExt2(String ext2) {
        this.ext2 = ext2 == null ? null : ext2.trim();
    }

    /**
     * 扩展字段3 
     * @return ext3 扩展字段3 
     */
    public String getExt3() {
        return ext3;
    }

    /**
     * 扩展字段3 
     * @param ext3 扩展字段3 
     */
    public void setExt3(String ext3) {
        this.ext3 = ext3 == null ? null : ext3.trim();
    }

    /**
     * 扩展字段4 
     * @return ext4 扩展字段4 
     */
    public String getExt4() {
        return ext4;
    }

    /**
     * 扩展字段4 
     * @param ext4 扩展字段4 
     */
    public void setExt4(String ext4) {
        this.ext4 = ext4 == null ? null : ext4.trim();
    }

    /**
     * 扩展字段5 
     * @return ext5 扩展字段5 
     */
    public String getExt5() {
        return ext5;
    }

    /**
     * 扩展字段5 
     * @param ext5 扩展字段5 
     */
    public void setExt5(String ext5) {
        this.ext5 = ext5 == null ? null : ext5.trim();
    }

    /**
     * 扩展字段6 
     * @return ext6 扩展字段6 
     */
    public String getExt6() {
        return ext6;
    }

    /**
     * 扩展字段6 
     * @param ext6 扩展字段6 
     */
    public void setExt6(String ext6) {
        this.ext6 = ext6 == null ? null : ext6.trim();
    }

    /**
     * 扩展字段7 
     * @return ext7 扩展字段7 
     */
    public String getExt7() {
        return ext7;
    }

    /**
     * 扩展字段7 
     * @param ext7 扩展字段7 
     */
    public void setExt7(String ext7) {
        this.ext7 = ext7 == null ? null : ext7.trim();
    }

    /**
     * 扩展字段8 
     * @return ext8 扩展字段8 
     */
    public String getExt8() {
        return ext8;
    }

    /**
     * 扩展字段8 
     * @param ext8 扩展字段8 
     */
    public void setExt8(String ext8) {
        this.ext8 = ext8 == null ? null : ext8.trim();
    }

    /**
     * 扩展字段9 
     * @return ext9 扩展字段9 
     */
    public String getExt9() {
        return ext9;
    }

    /**
     * 扩展字段9 
     * @param ext9 扩展字段9 
     */
    public void setExt9(String ext9) {
        this.ext9 = ext9 == null ? null : ext9.trim();
    }

    /**
     * 扩展字段10 
     * @return ext10 扩展字段10 
     */
    public String getExt10() {
        return ext10;
    }

    /**
     * 扩展字段10 
     * @param ext10 扩展字段10 
     */
    public void setExt10(String ext10) {
        this.ext10 = ext10 == null ? null : ext10.trim();
    }

    /**
     * 扩展字段11 
     * @return ext11 扩展字段11 
     */
    public String getExt11() {
        return ext11;
    }

    /**
     * 扩展字段11 
     * @param ext11 扩展字段11 
     */
    public void setExt11(String ext11) {
        this.ext11 = ext11 == null ? null : ext11.trim();
    }

    /**
     * 扩展字段12 
     * @return ext12 扩展字段12 
     */
    public String getExt12() {
        return ext12;
    }

    /**
     * 扩展字段12 
     * @param ext12 扩展字段12 
     */
    public void setExt12(String ext12) {
        this.ext12 = ext12 == null ? null : ext12.trim();
    }

    /**
     * 扩展字段13 
     * @return ext13 扩展字段13 
     */
    public String getExt13() {
        return ext13;
    }

    /**
     * 扩展字段13 
     * @param ext13 扩展字段13 
     */
    public void setExt13(String ext13) {
        this.ext13 = ext13 == null ? null : ext13.trim();
    }

    /**
     * 扩展字段14 
     * @return ext14 扩展字段14 
     */
    public String getExt14() {
        return ext14;
    }

    /**
     * 扩展字段14 
     * @param ext14 扩展字段14 
     */
    public void setExt14(String ext14) {
        this.ext14 = ext14 == null ? null : ext14.trim();
    }

    /**
     * 扩展字段15 
     * @return ext15 扩展字段15 
     */
    public String getExt15() {
        return ext15;
    }

    /**
     * 扩展字段15 
     * @param ext15 扩展字段15 
     */
    public void setExt15(String ext15) {
        this.ext15 = ext15 == null ? null : ext15.trim();
    }

    public void setFrontShow(String frontShow) {
        this.frontShow = frontShow;
    }

    public String getPayTypeShow() {
        if(null != payType){
            return 1 == payType ? "全款房；" : "按揭房；";
        }else{
            return "";
        }
    }

    public void setPayTypeShow(String payTypeShow) {
        this.payTypeShow = payTypeShow;
    }

    public String getBuildingTypeShow() {
        return StringUtils.isNotEmpty(buildingType) ? "房屋类型【" + buildingType + "】;" : "";
    }

    public void setBuildingTypeShow(String buildingTypeShow) {
        this.buildingTypeShow = buildingTypeShow;
    }

    public String getBuiltUpTimeShow() {
        return StringUtils.isNotEmpty(builtUpTime) ? "建立时间【" + builtUpTime + "】;" : "";
    }

    public void setBuiltUpTimeShow(String builtUpTimeShow) {
        this.builtUpTimeShow = builtUpTimeShow;
    }

    public String getBuildingPositionShow() {
        return StringUtils.isNotEmpty(buildingPosition) ? "房屋位置【" + buildingPosition + "】;" : "";
    }

    public void setBuildingPositionShow(String buildingPositionShow) {
        this.buildingPositionShow = buildingPositionShow;
    }

    public String getBuildingAreaShow() {
        return StringUtils.isNotEmpty(buildingArea) ? "房屋面积【" + buildingArea + "】;" : "";
    }

    public void setBuildingAreaShow(String buildingAreaShow) {
        this.buildingAreaShow = buildingAreaShow;
    }

    public String getMarketPriceShow() {
        return null != getMarketPrice() ? "市场价格【" + getMarketPrice()+ "万】;" : "";
    }

    public void setMarketPriceShow(String marketPriceShow) {
        this.marketPriceShow = marketPriceShow;
    }

    public String getCertificateShow() {
        return StringUtils.isNotEmpty(certificate) ? "房产证【" + certificate + "】;" : "";
    }

    public void setCertificateShow(String certificateShow) {
        this.certificateShow = certificateShow;
    }

    public String getTakingTimeShow() {
        return null != takingTime ? "拿证时间【" + DateUtil.dateToString(takingTime, "yyyy-MM-dd")+ "】;" : "";
    }

    public void setTakingTimeShow(String takingTimeShow) {
        this.takingTimeShow = takingTimeShow;
    }

    public String getIsTradeShow() {
        if(null != isTrade){
            return 1 == isTrade ? "是否可以交易【是】;" : "是否可以交易【否】;";
        }else{
            return "";
        }
    }

    public void setIsTradeShow(String isTradeShow) {
        this.isTradeShow = isTradeShow;
    }

    public String getMortgageBankShow() {
        return StringUtils.isNotEmpty(mortgageBank) ? "按揭银行【" + mortgageBank + "】;" : "";
    }

    public void setMortgageBankShow(String mortgageBankShow) {
        this.mortgageBankShow = mortgageBankShow;
    }

    public String getMortgageAmountShow() {
        return null != getMortgageAmount() ? "按揭金额【" + getMortgageAmount() + "万】;" : "";
    }

    public void setMortgageAmountShow(String mortgageAmountShow) {
        this.mortgageAmountShow = mortgageAmountShow;
    }

    public String getMortgageTimeShow() {
        return null != mortgageTime ? "按揭开始时间【" + DateUtil.dateToString(mortgageTime, "yyyy-MM-dd") + "】;" : "";
    }

    public void setMortgageTimeShow(String mortgageTimeShow) {
        this.mortgageTimeShow = mortgageTimeShow;
    }

    public String getMonthPayShow() {
        return null != getMonthPay() ? "月供【" + getMonthPay() + "元】;" : "";
    }

    public void setMonthPayShow(String monthPayShow) {
        this.monthPayShow = monthPayShow;
    }

    public String getMortgageYearsShow() {
        return null != mortgageYears ? "按揭年限【" + mortgageYears + "年】;" : "";
    }

    public void setMortgageYearsShow(String mortgageYearsShow) {
        this.mortgageYearsShow = mortgageYearsShow;
    }

    public String getMortgageRateShow() {
        return null != getMortgageRate() ? "按揭利率【" + getMortgageRate() + "%】;" : "";
    }

    public void setMortgageRateShow(String mortgageRateShow) {
        this.mortgageRateShow = mortgageRateShow;
    }

    public String getMortgageWayShow() {
        return StringUtils.isNotEmpty(mortgageWay) ? "按揭方式【" + mortgageWay + "】;" : "";
    }

    public void setMortgageWayShow(String mortgageWayShow) {
        this.mortgageWayShow = mortgageWayShow;
    }

    public String getRepaymentWayShow() {
        return StringUtils.isNotEmpty(repaymentWay) ? "还款方式【" + repaymentWay + "】;" : "";
    }

    public void setRepaymentWayShow(String repaymentWayShow) {
        this.repaymentWayShow = repaymentWayShow;
    }

    public String getFrontShow() {
        if(null != payType){
            if(payType == 1) {//全款
//                return getPayTypeShow() + getBuildingTypeShow() + getBuiltUpTimeShow() + getBuildingPositionShow() + getBuildingAreaShow() +
//                        getMarketPriceShow() + getCertificateShow() + getTakingTimeShow() + getIsTradeShow();
                return getPayTypeShow() + getBuildingTypeShow() + getBuiltUpTimeShow() + getBuildingPositionShow() + getBuildingAreaShow() +
                        getMarketPriceShow() + getCertificateShow();
            }else if(payType == 2){//按揭
//                return getPayTypeShow() + getBuildingTypeShow() + getBuiltUpTimeShow() + getBuildingPositionShow() + getBuildingAreaShow() +
//                        getMarketPriceShow() + getCertificateShow() + getTakingTimeShow() + getIsTradeShow() + getMortgageBankShow() +
//                        getMortgageAmountShow() + getMortgageTimeShow() + getMonthPayShow() + getMortgageYearsShow() + getMortgageRateShow() +
//                        getMortgageWayShow() + getRepaymentWayShow();
                return getPayTypeShow() + getBuildingTypeShow() + getBuiltUpTimeShow() + getBuildingPositionShow() + getBuildingAreaShow() +
                        getMarketPriceShow() + getCertificateShow() + getMortgageBankShow() +
                        getMortgageAmountShow() + getMortgageTimeShow() + getMonthPayShow() + getMortgageYearsShow() +
                        getMortgageWayShow() + getRepaymentWayShow();
            }else{
                return  "";
            }
        }else {
            return  "";
        }
    }
}